<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta content="text/html; charset=UTF-8; X-Content-Type-Options=nosniff" http-equiv="Content-Type" />
	<script src="js/app.api.js"></script>
	<script src="js/app.domain.js"></script>
<style type="text/css">
	.p-hr{height:0; border-top: 0px solid #EEEEEE; }
	.app-info{width:100%}
</style>

<div id="appstools_register_window">
	<div id="appstools_register_conent" class="wp_pl_15 wp_mr_15">
		<div class="wp_fz_12 wp_mt_10">Create an App</div>
		<table class="wp_w_480 wp_mt_15 wp_fz_12" border=0>
			<tr>
				<td rowspan="2" class="wp_w_40"><i class="app_tools_a_40_40"></i></td>
				<td colspan="5" class="wp_pl_10">Do you want to create</td>
			</tr>
			<tr>
				<td colspan="2" class="wp_w_140"><label><input type="radio" name="apptype" class="wp_ml_10" checked value="connector" data-bind="checked: radioValue" />Connector App</label></td>
				<td colspan="2" class="wp_w_100"><label><input type="radio" name="apptype" value="part" data-bind="checked: radioValue" />App Part</label></td>
				<td class="wp_w_200"><button type="button" class="left k-button wp_w_52 wp_h_20" style="background-color:#6cbf43!important" data-bind="click:prooeed">Prooeed</button></td>
			</tr>
		</table>
		<hr class="p-hr wp_mt_10" style="background:gray;"/>
		<div class="wp_fz_12 wp_mt_10">Edit an App</div>
		<table class="wp_w_480 wp_mt_15 wp_fz_12" border=0>
			<tr>
				<td class="wp_w_40"><i class="app_tools_b_40_40"></i></td>
				<td class="wp_pl_10">
				<table class="app-info" border=0>
					<tr><td><span id="totalinfo"></span></td></tr>
					<tr><td><span id="detailinfo"></span></td></tr>
				</table>
				</td>
			</tr>
		</table>
		<hr class="p-hr wp_mt_10" style="background:gray;"/>
		<div class="wp_h_180"></div>
		<div><button type="button" class="k-button wp_w_50 wp_h_20 wp_fz_12 right" data-bind="click:leave">Leave</button></div>
	</div>
</div>

<script  type="text/javascript">
var apps_tools_register = (function() {
	var viewmodel = kendo.observable({
		radioValue:'connector',
		prooeed:function(e){
			if(viewmodel.radioValue == "connector"){
				registerWin.data("kendoWindow").close();
				appsToolsCreateWin.apps_tools_win_create();
			} else {
				alert("App Part");
			}
		},
		leave:function(e){
			registerWin.data("kendoWindow").close();
		},
		link:function(e){
			registerWin.data("kendoWindow").close();
			apps_tools_register_editlist.showEditListWin();
		}
	});
	//kendo.bind($("#appstools_register_window"), viewmodel);
	var registerWin = $('#appstools_register_window');
	registerWin.kendoWindow({
		width:512,
		height:400,
		title:"Register My Apps",
		visible:false,
		modal: true,
		resizable: false,
		actions: ["Close"],
		close:function(){
			$("#totalinfo").html("");
			$("#detailinfo").html("");
			kendo.unbind(this.cardView, this.nameSpaceCardViewModel);
			registerWin.destroy;
		}
	});
	
	registerWin.parent().find('#appstools_register_win_wnd_title').css('font-size','12px');
	
	function getEditCount(){
		Workport.AppAPI.getStatus(getStatusCallBack);
	}
	
	function getStatusCallBack(data, httpCode){
		if(data.ResponseCode == "WP1026"){
			var editApp = data.EditAppCount;
			if(editApp.length != 0){
				var total = 0;
				for(var i = 0; i < editApp.length; i ++){
					if(i == editApp.length-1){
						$("#detailinfo").append(editApp[i].AppStatus + " : " + editApp[i].AppStatusCount + '.');
					} else
						$("#detailinfo").append(editApp[i].AppStatus + " : " + editApp[i].AppStatusCount + ', ');
					total += editApp[i].AppStatusCount;
				}
				$("#totalinfo").append("Total : " +"<a href='#' data-bind='click:link'>" + total +"</a>");
				
			} else {
				$("#totalinfo").append("Total : 0");
			}
		} else {
			alert(data.ResponseMessage);
		}
		kendo.bind($("#appstools_register_window"), viewmodel);
	}
	
	return {
		showRegisterWin:function(){
			getEditCount();
			registerWin.data("kendoWindow").center();
			registerWin.data("kendoWindow").open();
		}
	};
	
})();
</script>